<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="container light"><!--类名-->
        这是陕西 <br>
        这是陕西 <br>
        这是陕西 <br>
    </div>
     
    <style>/*去除浏览器默认样式*/
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
     
    html,body {/*让html标签和body标签和浏览器窗口一样高一样宽*/
        width: 100%;
        height: 100%;
    }
     
    .container {
        width: 100%;
        height: 100%;
     /*100%的意思为和父元素尺寸一样*/
    }
     
    .light {
        background-color: #f3f3f3;
        color: #333;
    }
     
    .dark {
        background-color: #333;
        color: #f3f3f3;
    }
    </style>

    <script>
    let di = document.querySelector('div');/*选中div*/
    di.onclick = function () {
        console.log(di.className);
        if (di.className.indexOf('light') != -1) {
            di.className = 'container dark';
        } else {
            di.className = 'container light';
        }
    }
    </script>

</body>
</html>
